package cn.wh.beans;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author wanghao
 * @Date 2022-08-24 20:56
 * @Description: TODO
 */
public class PropertyValues {
    private final List<PropertyValue> propertyValueList=new ArrayList<>();

    //添加
    public void addPropertyValue(PropertyValue p){
        this.propertyValueList.add(p);
    }

    /**
     * 将集合转为数组
     * @return
     */
    public PropertyValue[] getPropertyValues(){
        return this.propertyValueList.toArray(PropertyValue[]::new);
    }

    public PropertyValue getPropertyValue(String name){
        for (PropertyValue propertyValue : propertyValueList) {
            if (propertyValue.getName().equals(name))
                return propertyValue;
        }
        return null;
    }

}
